<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>淘宝</title>
  <style>
    * {
      box-sizing: border-box;
      padding: 0;
      margin: 0;
    }

    ul,
    li {

      list-style: none;
    }

    .container {
      position: relative;
      width: 519px;
      height: 278px;
      margin: auto;
    }

    .previous {
      position: absolute;
      top: 50%;
      right: 0;
      translate: 0 -50%;

      width: 40px;
      height: 40px;
      border-radius: 50% 0 0 50%;
      text-align: center;
      line-height: 38px;
      padding-left: 5px;
      color: white;
      font-size: 22px;
      background-color: rgba(0, 0, 0, .5);
    }

    .next {
      position: absolute;
      top: 50%;
      left: 0;
      translate: 0 -50%;

      width: 40px;
      height: 40px;
      border-radius: 0 50% 50% 0;
      line-height: 38px;
      padding-left: 5px;
      color: white;
      font-size: 22px;
      background-color: rgba(0, 0, 0, .5);

    }

    .container li {
      float: left;
      width: 10px;
      height: 10px;
      background-color: red;
      border-radius: 50%;
      margin: 0 5px;
      transition: 500ms;
    }
    .container li.active{
      float: left;
      width: 20px;
      height: 10px;
      background-color: red;
      border-radius: 10px;
      margin: 0 5px;
    }

    .container ul {
      display: inline-block;
      position: absolute;
      top: 5px;
      left: 50%;
      translate: -50%;
      padding: 3px;
      border-radius: 10px;
      /* 只要这个值大于容器的一半高度就行 */
      background-color: #005971;
      width: 118px;
    }
  </style>
</head>

<body>
  <div class="container">
    <img src="../img/tb.png" alt="">
    <div class="previous"> &gt;</div>
    <div class="next">&lt;</div>
    <ul>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
    </ul>

  </div>
  <script>
    const listItems = document.querySelectorAll('.container li');

    listItems.forEach(li => {
      li.addEventListener('click', () => {
        // 移除所有 li 的 active 类名
        listItems.forEach(item => item.classList.remove('active'));
        // 为当前点击的 li 添加 active 类名
        li.classList.add('active');
      });
    });
  </script>
</body>
</html>